package com.test01.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * author: xl
 * time: 2018/5/22 10:18
 * description:
 **/
@Controller
public class RedirectController {


    @RequestMapping(value = "/index", method = RequestMethod.GET)
    public String index() {
        return "test01/test";
    }

    @RequestMapping(value = "/staticPage", method = RequestMethod.GET)
    public String redirect() {
        return "redirect:/index";
    }

    @RequestMapping("/forwardTest")
    public String forwardTest(HttpServletRequest request, HttpServletResponse response){
        request.setAttribute("message", "hello");
        return "forward:/staticPage";  //forward在跳转后可以取到message值
    }


}
